def gen(i0, N):
    for i in xrange(i0, N):
        if i < 10 :
            yield str(i)
        elif i==10 :
            yield "A"
        elif i==11 :
            yield "B"
        elif i==12 :
            yield "C"
        elif i==13 :
            yield "D"
        elif i==14 :
            yield "E"
        elif i==15 :
            yield "F"

def f(p,N,K) :
    if K == 0 :
        print p
    else :
        for q in gen(0,N) :            
            f(p+q,N,K-1)

D_INPUT = True    
if D_INPUT:
    K,N = input()
else:
    K,N = 5,16

if K==1 : print 0 
for p0 in gen(1,N) :
    f(p0,N,K-1)